﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public class 引用
    {
        public string 姓名;
        public void RefDemo()
        {
            int age = 1;
            RefDemo2(ref age);
            Console.WriteLine(age);
            string num = "0";
            int num_int = 0;
            //1:将字符串“0”尝试转换成int
            //2:如果成功转换，则通过内存地址找到num_int的内存值，并将转换成功的值赋值
            //3:如果转换失败，原值保持不变
            //3:或者理解为，ref和out是将变量（值/引用）的内存地址进行传递
            int.TryParse(num, out num_int);    
        }
        public void RefDemo2(ref int age)
        {
            age += 10;
        }
    }
}
